import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['STHeiti', 'PingFang SC', 'Heiti TC', 'Microsoft YaHei', 'SimHei', 'Arial Unicode MS']  
plt.rcParams['axes.unicode_minus'] = False
# 年份
years = [2025, 2030, 2035, 2040, 2045, 2050]

# 二氧化碳排放数据（单位：亿吨）
high_emission = [50.4, 48.0, 42.6, 37.2, 31.2, 24.0]
baseline_emission = [42.0, 40.0, 35.5, 31.0, 26.0, 20.0]
low_emission = [33.6, 32.0, 28.4, 24.8, 20.8, 16.0]

# 创建图形
plt.figure(figsize=(6, 4))

# 添加灰色竖线
# for year in years[1:]:
#     plt.axvline(x=year - 2.5, color='#dadada', linestyle='-', linewidth=2)

# 绘制折线
plt.plot(years, high_emission, marker='o', label='高碳排放情景', color='#5174bf')
plt.plot(years, baseline_emission, marker='s', label='基准情景', color='#df8242')
plt.plot(years, low_emission, marker='^', label='低碳排放情景', color='#7da952')



# 设置图例、标签和标题
plt.xlabel('年份')
plt.ylabel('二氧化碳排放量（亿吨）')
# plt.title('不同情景下的二氧化碳排放量预测')
plt.ylim(0, 60)
plt.legend()
# plt.grid()
plt.tight_layout()

# 显示图形
plt.savefig("4.jpg", dpi=500)
